package net.peelmeagrape.hibernate.collections;

import net.peelmeagrape.hibernate.xmlgen.DefaultFromGenericType;
import net.peelmeagrape.hibernate.xmlgen.XmlAttribute;
import net.peelmeagrape.hibernate.xmlgen.XmlElement;
import net.peelmeagrape.hibernate.xmlgen.ChildElement;
import net.peelmeagrape.hibernate.Column;

import java.lang.annotation.Retention;
import static java.lang.annotation.RetentionPolicy.RUNTIME;

/**
 * Many to many association mapped to the key of a map. ie. a map keyed
 * on entities.
 */
@Retention(RUNTIME)
@XmlElement(name="map-key-many-to-many")
public @interface MapKeyManyToMany
{
    @XmlAttribute("class")
    @DefaultFromGenericType(0)
            Class[] targetClass() default {};
    @ChildElement(1) Column[] columnMapping() default {};

    @XmlAttribute("entity-name") String entityName() default "";
    /**
     * The name of the foreign key column. This may also be specified by nested {@link #columnMapping()} element(s).
     */
    @XmlAttribute String column() default "";
    @XmlAttribute String formula() default "";
    @XmlAttribute("foreign-key") String foreignKey() default "";
}
